﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QD.Web.Upload
{
    public abstract class File
    {
        public static string GetFileExtName(string fileName)
        {
            if (string.IsNullOrEmpty(fileName) || (fileName.IndexOf('.') <= 0))
            {
                return string.Empty;
            }
            fileName = fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'));
            return fileName.ToLower().Trim();
        }

        public static bool IsImage(string fileName)
        {
            string fileExtName = GetFileExtName(fileName);
            if (string.IsNullOrEmpty(fileExtName))
            {
                return false;
            }
            return ".jpg,.jpeg,.bmp,.gif,.png,.ico".Split(new char[] { ',' }).Contains<string>(fileExtName);
        }
    }
}
